home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1694 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.mindlink.net!news
  2. From: genew@mindlink.bc.ca (Gene Wirchenko)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: What is wrong ?
  5. Date: Tue, 16 Jan 1996 10:49:22 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4dfvu2$q18@fountain.mindlink.net>
  8. References: <4df373$kd3@ns.etri.re.kr>
  9. NNTP-Posting-Host: line023.nwm.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. jinsoo@etri.re.kr (Jin-Soo Lee) wrote:
  13.  
  14. > Your KIND HELP is needed.
  15. > I have some problems in the following code.
  16.  
  17. >---------
  18.  
  19. >#define DSKPAGESIZE     16*1024
  20. >#define LOGBUFSIZE      2*DSKPAGESIZE
  21.  
  22. >main()
  23. >{
  24. >    int    pageBS, logoffset, bufferoffset, buffersize, length;
  25. >    int    freespace, inusefile;
  26. >    char    *globla_page;
  27. >    T_LOGRECORD    *tlogrec;
  28. >....
  29. >(1)     pageBS = (logoffset/LOGBUFSIZE) * LOGBUFSIZE;
  30. >....
  31. >(2)     bufferoffset = (logoffset + length)%LOGBUFSIZE;
  32. >....
  33. >(3)     tlogrec = (T_LOGRECORD *)(global_page + (logoffset%LOGBUFSIZE));
  34. >....
  35. >        freespace = inuselogfile - logoffset;
  36. >(4)     if (freespace - length > sizeof(int))
  37. >....
  38. >        freespace = buffersize - bufferoffset;
  39. >(5)     if (freespace - length >= sizeof(int))
  40. >....
  41. >}
  42.  
  43. >---------
  44.  
  45. > The code worked well on SUN OS 4.1.3. and K&R C with dbx,
  46. > but goes wrong when moved to current environment,
  47. > Solaris 2.4 and SUN C with SparcWorks dbx and gcc with gdb.
  48. > The statements (1) ~ (5) sometimes make too big or negative values.
  49.  
  50.      If negative, it could be overflow.  Increase to long (assuming
  51. that's longer on your implementation).
  52.  
  53. > I can't believe it.
  54.  
  55.      Would your computer lie to you?  Don't you trust it?  <G>
  56.  
  57. > What happened ?
  58. > OS or compiler problem ? or C language syntax problem ?
  59.  
  60. > Any help is greatly appreciated. Please e-mail me.
  61.  
  62. >--
  63. >Jin-Soo Lee            Internet: jinsoo@dbserver.etri.re.kr
  64. >DB Section, Electronics and Telecommunications Research Inst. (ETRI)
  65. >P.O. Box 106, You-Seong, Taejon, 305-600, Korea
  66. >TEL: +82-42-860-4865                            FAX: +82-42-860-6645
  67.  
  68. C Pronunciation Guide:
  69.      y=x++;     "wye equals ex plus plus semicolon"
  70.      x=x++;     "ex equals ex doublecross semicolon"
  71.  
  72.